/***********************************************************
 *  File_Name  : XJCurl.h
 *  File_Path   : 
 *  File_Encode : UTF8
 *  Description : CURL操作类
 *  
 *  OS : Linux, UNIX,Windows,Other
 *  LastVersion  : 20120829
 *      
 *  Author      : LiXiujie(李秀杰)
 *  Date        : 2011-8-29
 *  Version     : 20120829
 *  Description : 
 *                
 *  Edit Author : 
 *  Edit Date   : 
 *  Version     : 
 *  Description :
 *                
 ***********************************************************/
#ifndef XJCURL_H_
#define XJCURL_H_

#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
#include <string>
#include <map>

namespace XJUtilClass{
typedef struct  _XJCurlBuf
{
	char *pData;
	size_t nMaxSize;
	size_t nSize;
}XJCurlBuf;

class XJCurl {
public:
	XJCurl();
	virtual ~XJCurl();
public:
	XJCurlBuf * XJCurlBufCreate();
	void XJCurlBufDelete(XJCurlBuf * buf);
	int XJGetHtml(XJCurlBuf *buf, const char *szURL);
	int XJPostHtml(XJCurlBuf *buf, const char *szURL, const char *szPostData);
	int XJPutHtml(XJCurlBuf *buf, const char *szURL);
	int XJDeleteHtml(XJCurlBuf *buf, const char *szURL);
	int XJAddHeadValue(const std::string strName, const std::string strValue);
	int XJDelHeadValue(const std::string strName);
	int XJCleanHeadValue();
	void XJSetCookiePath(const std::string &CookiePath);
	std::string XJGetCookiePath();
	std::string XJEscape(const std::string &strFieldValue);
	std::string XJUnescape(const std::string &strFieldValue);
private:
	void CommonSetOpt(void *pCurl);
private:
	std::string m_strCookiePath;
	static size_t my_curl_fwrite(void *buffer, size_t size, size_t nmemb, void *stream);
	std::map<std::string, std::string> m_mapHeadValue;
};
}//namespace XJUtilClass
#endif /* XJCURL_H_ */
